<?php
// $Header: /cvsroot/bitweaver/_bit_moderate/index.php,v 1.5 2006/06/13 16:13:10 sylvieg Exp $
// Copyright (c) 2004 bitweaver Moderate
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.

// Initialization
require_once( '../bit_setup_inc.php' );

// Is package installed and enabled
$gBitSystem->verifyPackage( 'moderate' );

// Now check permissions to access this page
$gBitSystem->verifyPermission( 'p_moderate_view' );

require_once(MODERATE_PKG_PATH.'Moderate.php');

$m = new Moderate();

if (!empty($_REQUEST['action'])) {
	if ($_REQUEST['action']=='revert') {
		$s = !empty($_REQUEST['smart']);
		$m->revert($_REQUEST['item'],$s);
	} elseif ($_REQUEST['action']=='delete') {
		$m->delete($_REQUEST['item']);
	} elseif (($_REQUEST['action']=='report')&&(!empty($_REQUEST['for']))) {
		if (($_REQUEST['for']=='spam') || ($_REQUEST['for']=='offensive')) {
			//Moderate::invokeServiceFunctionR('content_set_rating_function',array($_REQUEST['item'],1));
		} elseif ($_REQUEST['for']=='bug') {
			// file bug
			$exp = $gBitSystem->getConfig("moderate_bug_exp",'http://trac.example.com/newticket?summary=$summary&description=$description&reporter=$email&keywords=$keyword');
			//$exp = 'http://trac.wikiwise.com/newticket?summary=$summary&description=$description&reporter=$email&keywords=$keyword';
			$data = array(
			'$email' => $gBitUser->mInfo['email'],
			'$summary' => "url:{$_REQUEST['ref']}",
			'$description' => urlencode("url:{$_REQUEST['ref']}\nplease describe the bug that occurs at the above url"),
			'$keyword' => "autobug",
			);

			header("Location: ".str_replace(array_keys($data),array_values($data),$exp));
			die();
		}

		if (!empty($_REQUEST['item']) && (($_REQUEST['for']=='spam') || ($_REQUEST['for']=='offensive') ||  ($_REQUEST['for']=='illegal'))) {
			$obj = $gLibertySystem->getLibertyObject($_REQUEST['item']);
			$obj->storePreference("mod_".$_REQUEST['for'],1);
		}

	} elseif (($_REQUEST['action']=='unmark')&&(!empty($_REQUEST['for']))&&(!empty($_REQUEST['item']))) {
		$obj = $gLibertySystem->getLibertyObject($_REQUEST['item']);
		$obj->storePreference("mod_".$_REQUEST['for'],'');
	}

	header("Location: http://".$_REQUEST['ref']);
}

$l = $m->getList($_REQUEST);
$gBitSmarty->assign_by_ref('modList',$l);

// Display the template
$gBitSystem->display( 'bitpackage:moderate/moderate_display.tpl', tra( 'Moderate' ) );

?>
